package com.mew.chess.core.game.dyj.game.message;

import com.zebra.common.ZebraBaseMessage;
import io.netty.buffer.ByteBuf;
import lombok.Data;
import lombok.ToString;

import java.util.HashMap;
import java.util.Map;

/**
 * @author dylin
 * @create 2021/4/25
 */
@Data
@ToString
public class PushBetMessage extends ZebraBaseMessage<PushBetMessage> {
    private BetRecordMessage[] chipBets;//压注列表
    private long totalNumber; //总压
    private Map<Integer,Long> typeNumber=new HashMap<>();//各个区域压注

    @Override
    public void write(ByteBuf b) {

        writeInt(b,chipBets.length);
        for (BetRecordMessage chipBet : chipBets) {
            chipBet.write(b);
        }
        writeLong(b,totalNumber);
        writeInt(b,typeNumber.size());
        typeNumber.entrySet().stream().forEach(entry->{
            writeInt(b,2);
            writeLong(b,entry.getKey());
            writeLong(b,entry.getValue());
        });
    }

    @Override
    public PushBetMessage read(ByteBuf b) {
        return null;
    }

}
